import { adminAPI, commonAPI } from './http'

// 获取文章列表
export const getArticles = (offset = 0, limited = 10) => {
  console.log({offset, limited})
  return adminAPI.post('/api/v1/articleList', {
    offset,
    limited
  })
}

// 根据id删除文章
export const deleteArticleById = (id) => {
  return adminAPI.post(`/api/v1/articleDelete/${id}`)
}

// 通过id获取文章
export const getArticleById = (id) => {
  return adminAPI.post(`/api/v1/article/${id}`)
}

// 通过id保存文章
export const saveArticleById = (id, data) => {
  return adminAPI.post(`/api/v1/articleSave/${id}`, data)
}

// 添加文章
export const addArticle = (data) => {
  return adminAPI.post('/api/v1/addArticle', data)
}

// 获取文章阅读量
export const getArticleAmount = () => {
  return adminAPI.post('/api/v1/articleAmount')
}

// 获取文章数量
export const getArticleCount = () => {
  return adminAPI.post('/api/v1/articleCount')
}

// 获取通知列表
export const getNotifications = () => {
  return adminAPI.post('/api/v1/notifications')
}

// 用户登录
export const loginApi = (userInfo) => {
  return commonAPI.post('/api/v1/login', userInfo)
}
